home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_300 / 334_03 / t410x.trm < prev    next >
Text File  |  1991-02-04  |  5KB  |  240 lines

  1. /* GNUPLOT - t410x.trm */
  2. /*
  3.  * Copyright (C) 1990   
  4.  *
  5.  * Permission to use, copy, and distribute this software and its
  6.  * documentation for any purpose with or without fee is hereby granted, 
  7.  * provided that the above copyright notice appear in all copies and 
  8.  * that both that copyright notice and this permission notice appear 
  9.  * in supporting documentation.
  10.  *
  11.  * Permission to modify the software is granted, but not the right to
  12.  * distribute the modified code.  Modifications are to be distributed 
  13.  * as patches to released version.
  14.  *  
  15.  * This software  is provided "as is" without express or implied warranty.
  16.  * 
  17.  * This file is included by ../term.c.
  18.  *
  19.  * This terminal driver supports: Tektronix 410x and 420x series terminals
  20.  *
  21.  * AUTHORS
  22.  *   Colin Kelley, Thomas Williams
  23.  * 
  24.  * send your comments or suggestions to (pixar!info-gnuplot@sun.com).
  25.  * 
  26.  */
  27.  
  28. /* Tektronix 410X and 420X driver written by Cary D. Renzema.
  29.  * email address: caryr@vice.ico.tek.com
  30.  *
  31.  * I've tested this driver on the following terminals: 4106, 4107A, 4109
  32.  * and 4207.  It should work, without editing, on other terminals in the
  33.  * 410x and 420x families.  It will probably need to be changed to work
  34.  * on a 4105 (screen size and character rotation are two guesses).  This
  35.  * file can also be used as a start for a 411x driver.
  36.  *
  37.  * Cary R.
  38.  * April 5, 1990
  39.  */
  40.  
  41. #ifdef T410X
  42.  
  43. #define T410XXMAX 4095
  44. #define T410XYMAX 3131
  45.  
  46. #define T410XVCHAR    71
  47. #define T410XHCHAR    51
  48. #define T410XVTIC    36
  49. #define T410XHTIC    36    
  50.  
  51. static int T410X_angle=0;
  52.  
  53. T410X_init()
  54. {
  55.     (void) fprintf(outfile, "\033%%!0\033MN0\033MCB7C;\033MQ1\033MT1");
  56.     (void) fprintf(outfile, "\033MG1\033RK!\033SK!\033LZ\033%%!1");
  57. /*
  58.      1. set tek mode
  59.      2. set character path to 0 (characters placed equal to rotation)
  60.      3. set character size to 59 height
  61.      4. set character precision to string
  62.      5. set character text index to 1
  63.      6. set character write mode to overstrike
  64.      7. clear the view
  65.      8. clear the segments
  66.      9. clear the dialog buffer
  67.     10. set ansi mode
  68. */
  69.     (void) fflush(outfile);
  70. }
  71.  
  72.  
  73. T410X_reset()
  74. {
  75.     (void) fprintf(outfile, "\033%%!0\033LZ\033%%!1");
  76. /*
  77.     1. set tek mode
  78.     2. clear the dialog buffer
  79.     3. set ansi mode
  80. */
  81.     (void) fflush(outfile);
  82. }
  83.  
  84.  
  85. T410X_graphics()
  86. {
  87.     (void) fprintf(outfile, "\033%%!0\033\014\033LV0");
  88. /*
  89.     1. set tek mode
  90.     2. clear the screen
  91.     3. set dialog area invisible
  92. */
  93.     (void) fflush(outfile);
  94. }
  95.  
  96. T410X_text()
  97. {
  98.     (void) fprintf(outfile, "\033LV1\033%%!1");
  99. /*
  100.     1. set dialog area visible
  101.     2. set ansi mode
  102. */
  103.     (void) fflush(outfile);
  104. }
  105.  
  106.  
  107. T410X_move(x, y)
  108. unsigned int x, y;
  109. {
  110.     (void) fprintf(outfile, "\033LF");
  111.     (void) T410X_encode_x_y(x, y);
  112.     (void) fflush(outfile);
  113. }
  114.  
  115.  
  116. T410X_vector(x, y)
  117. unsigned int x, y;
  118. {
  119.     (void) fprintf(outfile, "\033LG");
  120.     (void) T410X_encode_x_y(x, y);
  121.     (void) fflush(outfile);
  122. }
  123.  
  124.  
  125. T410X_point(x, y, number)
  126. unsigned int x, y;
  127. int number;
  128. {
  129.     (void) fprintf(outfile, "\033MM");
  130.     (void) T410X_encode_int(max(number, 0)%11);
  131.     (void) fprintf(outfile, "\033LH");
  132.     (void) T410X_encode_x_y(x, y);
  133.     (void) fflush(outfile);
  134. }
  135.  
  136.  
  137. T410X_linetype(linetype)
  138. int linetype;
  139. {
  140.     switch (linetype) {
  141.         case -1:
  142.             (void) fprintf(outfile, "\033ML5");
  143.             break;
  144.         case -2:
  145.             (void) fprintf(outfile, "\033ML?");
  146.             break;
  147.         default:
  148.             (void) fprintf(outfile, "\033ML");
  149.             (void) T410X_encode_int(linetype%14+2);
  150.             break;
  151.     }
  152.     (void) fprintf(outfile, "\033MV");
  153.     (void) T410X_encode_int(max(linetype, 0)%8);
  154.     (void) fflush(outfile);
  155. }
  156.  
  157.  
  158. T410X_put_text(x, y, str)
  159. unsigned int x, y;
  160. char str[];
  161. {
  162.     extern int T410X_angle;
  163.  
  164.     if (T410X_angle == 0) {
  165.         (void) T410X_move(x, y-T410XVCHAR/2+6);
  166.         (void) fprintf(outfile, "\033MR00");
  167.     } else {
  168.         (void) T410X_move(x+T410XHCHAR/2-6, y);
  169.         (void) fprintf(outfile, "\033MRE:0");
  170.     }
  171.     (void) fprintf(outfile, "\033LT");
  172.     (void) T410X_encode_int(strlen(str));
  173.     (void) fputs(str, outfile);
  174.     (void) fflush(outfile);
  175. }
  176.  
  177. T410X_text_angle(ang)
  178. int ang;
  179. {
  180.     extern int T410X_angle;
  181.  
  182.     T410X_angle = ang;
  183.     return(TRUE);
  184. }
  185.  
  186. /* These last two routines are based on fortran code found in the
  187.  * 4106/4107/4109/CX PROGRAMMERS manual.
  188.  */
  189.  
  190. T410X_encode_x_y(x, y)
  191. unsigned int x, y;
  192. {
  193.     static char chix=0, chiy=0, cloy=0, ceb=0;
  194.  
  195.     register unsigned int hix, lox, hiy, loy, eb, lx, ly;
  196.  
  197.     lx = (x <= T410XXMAX) ? x : T410XXMAX;
  198.     ly = (y <= T410XYMAX) ? y : T410XYMAX;
  199.  
  200.     hix = lx/128 + 32;
  201.     lox = (lx/4)%32 + 64;
  202.     hiy = ly/128 + 32;
  203.     loy = (ly/4)%32 + 96;
  204.     eb = (ly%4)*4 + lx%4 + 96;
  205.  
  206.     if (chiy != hiy) (void) putc(hiy, outfile);
  207.     if (ceb != eb) (void) putc(eb, outfile);
  208.     if ((cloy!=loy) || (ceb!=eb) || (chix!=hix)) (void) putc(loy, outfile);
  209.     if (chix != hix) (void) putc(hix, outfile);
  210.     (void) putc(lox, outfile);
  211.  
  212.     chix = hix;
  213.     chiy = hiy;
  214.     cloy = loy;
  215.     ceb = eb;
  216. }
  217.  
  218.  
  219. T410X_encode_int(number)
  220. int number;
  221. {
  222.     register unsigned int mag, hi1, hi2, lo;
  223.  
  224.     mag = abs(number);
  225.  
  226.     hi1 = mag/1024 + 64;
  227.     hi2 = (mag/16)%64 + 64;
  228.     lo = mag%16 + 32;
  229.  
  230.     if (number >= 0) lo += 16;
  231.  
  232.     if (hi1 != 64) (void) putc(hi1, outfile);
  233.     if ((hi2 != 64) || (hi1 != 64)) (void) putc(hi2, outfile);
  234.     (void) putc(lo, outfile);
  235.  
  236. }
  237.  
  238.  
  239. #endif /* T410X */
  240.